package com.tinem.platform.module.starter.jpa.repository.network;

import com.tinem.platform.module.starter.jpa.entity.network.IpRangeInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * @program: platform
 * @description: ${description}
 * @author: eden#can
 * @Slogan: 没有所谓失败，除非你不再尝试
 * @date: 2022-05-14 11:23
 **/
@Repository
public interface IpRangeInfoRepository extends JpaRepository<IpRangeInfo, String> {


    @Query(
            nativeQuery = true,
            value = "select *  from t_iprange_info where " +
                    " :ipNum between  c_ip_start_num  and c_ip_end_num " +
                    " order by c_id asc limit 1"
    )
    Optional<IpRangeInfo> findIpv4InfoByIpNum(@Param("ipNum") long ipNum);
}
